package com.example.teacherservice.repository;

import com.example.teacherservice.entity.QuestionCollection;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Optional;

// QuestionCollectionRepository.java
public interface QuestionCollectionRepository extends JpaRepository<QuestionCollection, Long> {
    Optional<QuestionCollection> findByStudentIdAndQuestionId(Long studentId, Long questionId);
    List<QuestionCollection> findByStudentId(Long studentId);

    @Modifying
    @Query("DELETE FROM QuestionCollection qc WHERE qc.questionId = :questionId")
    void deleteByQuestionId(@Param("questionId") Long questionId);
}
